# jwt 生成
import jwt
# 密钥类
class MyJwt:

    def __init__(self):
        # 初始化密钥
        self.password = '123'

    # 加密
    def encode_jwt(self,userinfo):
                          # 用户信息   密钥           算法
        mystr = jwt.encode(userinfo, self.password, algorithm='HS256')
        try:
            mystr = str(mystr,'utf-8')
        except Exception as e:
            # print(e)
            pass
        return mystr

    #解密
    def decode_jwt(self,mystr):
        return jwt.decode(mystr,self.password,algorithms=['HS256'])


myjwt = MyJwt()
